import { DataTypes } from 'sequelize';
import { Migration } from '../umzug';

export const up: Migration = async ({ context: sequelize }) => {
  await sequelize.getQueryInterface().createTable(
    'feedbacks',
    {
      id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
      uuid: { type: DataTypes.STRING(36), unique: true },
      fk_conclusion: {
        type: DataTypes.INTEGER,
        references: {
          model: {
            tableName: 'conclusions',
          },
          key: 'id',
        },
      },
      upper: { type: DataTypes.INTEGER },
      lower: { type: DataTypes.INTEGER },
      description: { type: DataTypes.TEXT },
      created_at: { type: DataTypes.DATE },
      updated_at: { type: DataTypes.DATE },
    }
  );
};

export const down: Migration = async ({ context: sequelize }) => {
  await sequelize.getQueryInterface().dropTable('feedbacks');
};
